package com.yxx.mapper;

import com.github.pagehelper.Page;
import com.yxx.annotation.AutoFill;
import com.yxx.medicinecommon.enumeration.OperationType;
import com.yxx.medicinepojo.dto.EmployeePageQueryDTO;
import com.yxx.medicinepojo.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author yuxiangxun
 * @date 2024/9/5
 * @apiNote
 */
@Mapper
public interface EmployeeMapper {
    /**
     * 员工分页查询
     * @param employeePageQueryDTO
     * @return
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 登录 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 更新员工信息
     * @param employee
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Employee employee);

    @Select("select * from employee where id = #{id}")
    Employee select_Employee_id(Long id);

    /**
     * 插入员工信息
     * @param employee
     */
    @Insert(
            "insert into employee(name,username,password,phone,sex,id_number,status,create_time,update_time,create_user,update_user)" +
                    "values" +
                    "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})"
    )
    @AutoFill(value = OperationType.INSERT)
    void insert(Employee employee);

    /**
     * 根据员工id查询员工信息
     * @param userId
     * @return
     */
    @Select("select * from employee where id = #{userId}")
    Employee getByEmployeeId(Long userId);
}
